package com.yangoxix.lovegoing.controller;


import com.yangoxix.lovegoing.page.ActivityDetail;
import com.yangoxix.lovegoing.page.ActivityPage;
import com.yangoxix.lovegoing.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping("activity")
@Api(tags = "活动管理接口")
public class ActivityController {

    @Autowired
    private ActivityService service;


    //    获取活动
    @GetMapping("getActivity")
    @ResponseBody
    public ArrayList<ActivityPage> getActivity() {
        ArrayList<ActivityPage> activityPages = service.buildAllActivityPage();
        return activityPages;
    }


    //    获取活动详情
    @GetMapping("getDetail")
    @ResponseBody
    public ActivityDetail getActivityDetail(String name) {
        return service.getDetailById(name);
    }

//    删除活动接口
@ApiOperation("删除活动的接口")
    @GetMapping("deleteAct")
    @ResponseBody
    public void deleteAct(String name){
        service.deleteAct(name);
    }
}
